﻿using System.Windows.Forms;
using ShkSimulation.core.optimization;
using ShkSimulation.core.optimization.algorithm;
using ShkSimulation.core.optimization.algorithm.classicGeneticAlgotithm;
using ShkSimulation.carsharing.impl;

namespace ShkSimulation.desktop.component.tools {

	public partial class AlgorithmControl : UserControl {

		private DefaultOptimizationNetwork OptimizationNetwork { get; set; }
		
		private SimulationApplication application;

		public AlgorithmControl() {
			InitializeComponent();
			this.Dock = DockStyle.Fill;
			this.MutationStrategyComboBox.SelectedIndex = 0;
			this.CrossStrategyComboBox.SelectedIndex = 0;
		}
		
		public void SetSimulationApplication(SimulationApplication app) {
			this.application = app;
		}

		public OptimizationAlgorithm GetAlgorithm() {
			ClassicGeneticAlgorithm algorithm = new ClassicGeneticAlgorithm((int)PopulationSizeNumeric.Value, 
				(int)GenerationNumeric.Value, 
				(double)ElitePercentNumeric.Value, 
				double.Parse(MutationPropertyTextBox.Text), 
				CrossStrategyComboBox.SelectedIndex, 
				MutationStrategyComboBox.SelectedIndex,
				StopAtGenerationCheckBox.Checked, 
				StopAtConvergenceCheckBox.Checked, double.Parse(StopAtConvergenceTextBox.Text),
				StopAtEvaluationCheckBox.Checked, double.Parse(StopAtEvaluationTextBox.Text));
			return algorithm;
		}

	}

}